package SellCar.controller;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;


import SellCar.pojo.Sell;
import SellCar.service.impl.SellBizImpl;

@Controller("sellController")
public class SellController{
	@Autowired
	@Qualifier("sellBizImpl")
	private SellBizImpl sellBizImpl;
	
	ModelAndView mav = new ModelAndView();
	@RequestMapping(value="sellCar.html")
	public ModelAndView SellCar(@RequestParam("carName")String carName,
						@RequestParam("year")String year,
						@RequestParam("price")Integer price,
						@RequestParam("particulars")String particulars,
						@RequestParam("image")String image){
		Integer count = sellBizImpl.addInfo(carName, year, price, particulars, image);
		if(count>0){
			List<Sell> sellList = sellBizImpl.showSellInfo(carName, year, price, particulars, image);
			mav.addObject("sellList", sellList);
			mav.setViewName("showSell2");
			return mav;
		}else{
			//重定向
			return new ModelAndView("redirect:Error");
		}
		
	}
	
}
